package com.micromall.service.impl;

import com.micromall.model.AlRegion;
import com.micromall.mapper.AlRegionMapper;
import com.micromall.service.IAlRegionService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * ${table.comment} 服务实现类
 * </p>
 *
 * @author Dante Fung
 * @since 2017-07-28
 */
@Service
public class AlRegionServiceImpl extends ServiceImpl<AlRegionMapper, AlRegion> implements IAlRegionService {

    @Override
    public String getFullAddress(String areaId, String address) {
        // 区
        AlRegion regionQuery = new AlRegion();
        regionQuery.setRegionId(areaId);
        AlRegion alRegion = selectById(regionQuery);
        String area = alRegion.getRegionName();
        // 市
        regionQuery.setRegionId(alRegion.getParentRegionId());
        alRegion = selectById(regionQuery);
        String city = alRegion.getRegionName();
        // 省
        regionQuery.setRegionId(alRegion.getParentRegionId());
        alRegion = selectById(regionQuery);
        String province = alRegion.getRegionName();
        StringBuilder sb = new StringBuilder();
        sb.append(province).append(city).append(area).append(address);
        return sb.toString();
    }
}
